package com.legolas.consumer.web.controller;

import com.legolas.consumer.service.ConsumerSeckillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/8/4 0004
 */
@Controller
@RequestMapping("/sec")
public class SeckillController {

    /**
     * buyGoods方法不进行失败重试操作
     */
    @Autowired
    ConsumerSeckillService consumerSeckillService;

    @RequestMapping("/getGoods")
    @ResponseBody
    public List getAllGoods() {
        return consumerSeckillService.getAllGoods();
    }

    @RequestMapping("/addGoods")
    @ResponseBody
    public HttpEntity addGoods(String name, Integer stock) {
        return consumerSeckillService.addGoods(name, stock);
    }

    @RequestMapping("/buyGoods")
    @ResponseBody
    public HttpEntity buyGoods(Integer id) {
        return consumerSeckillService.buyGoods(id);
    }

    @RequestMapping("/addStock")
    @ResponseBody
    public HttpEntity addStock(Integer id) {
        return consumerSeckillService.addStock(id);
    }
}
